package com.wt.struggle.goodbye.main.activity

import android.os.Bundle
import android.os.Message
import com.google.gson.reflect.TypeToken
import com.wt.struggle.goodbye.R
import com.wt.struggle.goodbye.base.Config
import com.wt.struggle.goodbye.base.ProActivity
import com.wt.struggle.goodbye.base.Send
import com.wt.struggle.goodbye.info.NetInfo
import com.wt.struggle.goodbye.info.NewsInfo
import com.wt.struggle.goodbye.sq.fragment.SqFragment

/**
 * 社区精选
 */
class HandPickActivity : ProActivity() {

    override fun handler(what: Int, arg1: Int, netInfo: NetInfo) {
        when (what) {
            Send.MY_NEWS_CODE -> {

                if (netInfo.code == Config.SUCCESS) {
                    val result = netInfo.dataResult
                    initFragment(result)
                }
            }
        }
    }

    private fun initFragment(result: String?) {
        val manager = supportFragmentManager
        val t = manager.beginTransaction()
        val fragment = SqFragment()
        fragment.sheQuResult = result!!
        t.add(R.id.fragmentPick, fragment)
        t.commit()

    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.hand_pick_layout)

        val id = intent.getIntExtra("id", 0)

        getSheQuList(id)

    }

    private fun getSheQuList(id: Int) {
        /// 获取精选社区
        send!!.getSQList(1, 0, "", handler)
    }
}